#include "course.h"

/*for counting courses*/
int getCourseNum(struct Course *courses)
{
    int courseCount = 0;
    int i = -1;
    while (1)
    {
        i++;
        // course code is empty, then exit
        if (courses[i].code[0] == '\0')
        {
            break;
        }
        courseCount++;
    }
    return courseCount;
}

/*for counting grade items*/
int getGradeItemNum(struct Course course)
{
    int gradeitemCount = 0;
    int i = -1;
    while (1)
    {
        i++;
        // grade item is empty, then exit
        if (course.gradeitems[i].name[0] == '\0')
            break;
        gradeitemCount++;
    }
    return gradeitemCount;
}

/*for counting grades*/
int getGradeNum(struct GradeItem gradeitem){
    int gradeCount = 0;
    int i=0;
    while (gradeitem.grades[i] >= 0){
        gradeCount++;
        i++;
    }
    return gradeCount;
}